public class book {

    public static void main2(String[] args) {
        Object[] arr = new Object[10];
        Integer a = 1;
        Character b = '2';
        String c = "34";
        arr[0] = a;
        arr[1] = b;
        arr[2] = c;

    }

    //包装类
    public static void main1(String[] args) {

        int a = 0;
        //装箱
        Integer integer = Integer.valueOf(a);
//        Integer integer1 = new Integer(a);
        //拆箱
        int b = integer.intValue();

        int c = 0;
        //自动装箱
        Integer integer2 = c;
        Integer integer3 = (Integer) c;
        //自动拆箱
        int d = integer2;
        int e = (int) integer2;
    }

    public static <T> void text(T val) {
        System.out.println("this is a text"+val);
    }

    public static void main(String[] args) {
        storage<Integer> arrI = new storage<>();//这个对象储存的是Integer类型的数据
        storage<Character> arrC = new storage<>();//这个对象储存的是Character类型的数据
        for (int i = 0; i < 5; i++) {
            arrI.put(i, i);
        }
        int index = 0;
        for (char i = 'a'; i < 'e'; i++) {
            arrC.put(index++, (Character) i);
        }
        book.<String>text("  泛型静态方法");
        text(111);
        text('a');
    }
}

class storage<T>{//这样的话传入的类型必须是Number这个类的子类才可以
    Object[] arr;

    public storage() {
        arr = new Object[10];
    }


    public void put(int index,T val) {
        arr[index] = val;
    }

    public T get(int index) {
        return (T) arr[index];
    }
}


//
//class fanxin<数据类型> {
//    数据类型 b;
//    public fanxin(数据类型 a){}
//}